package com.yayawan.laomigame;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;

import com.yayawan.laomigame.callback.LaomiGameApi;
import com.yayawan.proxy.GameApi;
import com.yayawan.utils.FileUtils;
import com.yayawan.utils.Sputils;
import com.yayawan.utils.Yayalog;

import java.io.File;

public class InitApkBroadCastReceiver extends BroadcastReceiver {


    public static String filepath="";
    @Override
    public void onReceive(Context context, Intent intent) {





        PackageManager manager=context.getPackageManager();
        if((intent.getAction().equals(Intent.ACTION_PACKAGE_ADDED))||(intent.getAction().equals(Intent.ACTION_PACKAGE_REPLACED))) {

            String packageName=intent.getData().getSchemeSpecificPart();

            Yayalog.loger("安装成功"+packageName+" path"+intent.getData().getPath());

             int b=  Sputils.getSPint(Constant.ISINSTALLAPKDELETE, 0, context);
            // boolean b = Sputils.putSPint(Constant.ISINSTALLAPKDELETE, key, mActivity);
            //0 为不删，。1 为删  安装成功后删除包
                if (b==1){
                   // TasksManagerActivity.deleItem(packageName);
                    TasksManagerActivity.deleItem(packageName);
                }else {

                }


            // Toast.makeText(context,"安装成功"+packageName, Toast.LENGTH_LONG).show();

        }if(intent.getAction().equals(Intent.ACTION_PACKAGE_REMOVED)) {

            String packageName=intent.getData().getSchemeSpecificPart();
            Yayalog.loger("安装成功"+packageName+" path"+intent.getData().getPath());
            //Toast.makeText(context,"卸载成功"+packageName, Toast.LENGTH_LONG).show();

        }





    }

}
